package com.utils.validate;


import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

public abstract class Detect {




	public static final String EMPTY_STRING = StringUtils.EMPTY;

	
	/**  */
	public static boolean notEmpty(String string) {
		return null != string && !EMPTY_STRING.equals(string) && !"\"null\"".equals(string)  && !"null".equals(string)&& !"undefined".equals(string); 
	}
	public static boolean notEmpty(byte[] bytes) {
		return (null != bytes && 0 < bytes.length);
	}

	public static boolean notEmpty(List<?> list) {
		return null != list && !list.isEmpty();
	}

	public static boolean notEmpty(Map<?, ?> map) {
		return null != map && !map.isEmpty();
	}

	public static boolean notEmpty(Collection<?> collection) {
		return null != collection && !collection.isEmpty();
	}

/*	public static boolean notEmpty(String[] array) {
		return null != array && array.length > 0;
	}*/

	public static boolean notEmpty(short[] array) {
		return null != array && array.length > 0;
	}
	
	public static boolean notEmpty(int[] array) {
		return null != array && array.length > 0;
	}

	public static boolean notEmpty(long[] array) {
		return null != array && array.length > 0;
	}
	
	public static boolean notEmpty(String[] array) {
		return null != array && array.length > 0;
	}
	
	public static boolean notEmpty(Integer value) {
		return null != value && value!=0;
	}
	
	public static boolean notEmpty(BigDecimal value) {
		return null != value && value.doubleValue()!=0;
	}
	public static boolean notEmpty(Long value) {
		return null != value&& value!=0 ;
	}
	
	
	
	
	public static <T extends Object> boolean notEmpty(T[] array) {
		return null != array && array.length > 0;
	}

	//非空且小于0
	public static boolean isNegative(Double value) {
		return value != null && value < 0;
	}
	//非空且大于0
	public static boolean isPositive(BigDecimal value) {
		return null != value ;
	}
	public static boolean isPositive(Double value) {
		return value != null && value.doubleValue() > 0;
	}
	public static boolean isPositive(Short value) {
		return value != null && value.shortValue() > 0;
	}
	public static boolean isPositive(Long value) {
		return value != null && value.longValue() > 0;
	}
	public static boolean isPositive(Integer value) {
		return value != null && value.intValue() > 0;
	}
	
	public static boolean isPositives(Long value) {
		return value != null && value.longValue() >= 0;
	}

	public static boolean isTrue(Boolean value) {
		return Boolean.TRUE.equals(value);
	}

	public static boolean isFalse(Boolean value) {
		return Boolean.FALSE.equals(value);
	}

	/**  */
	public static boolean contains(long value, long[] values) {
		if (notEmpty(values)) {
			int length = values.length;
			for (int i = 0; i < length; i++) {
				if (values[i] == value) {
					return true;
				}
			}
		}
		return false;
	}
	
	/**  */
	public static boolean containsAll(long[] values, long[] subValues) {
		if (!notEmpty(values) && !notEmpty(subValues)) {
			return true;
		}
		if (notEmpty(subValues)) {
			for (int i = 0; i < subValues.length; i++) {
				if (!contains(subValues[i], values)) {
					return false;
				}
			}
			return true;
		} else if (notEmpty(values)){
			return true;
		} 
		return false;
	}

	public static <E> boolean contains(E one, List<E> list) {
		if (notEmpty(list) && null != one) {
			for (E item : list) {
				if (one.equals(item)) {
					return true;
				}
			}
		}
		return false;
	}

}
